package com.designmodel.designmodel.Strategy_Pattern策略模式;

/**
 * 用来排序
 */
public class DataSort {


	public static void sort(Object[] objects){

		for (int i=0;i<objects.length;i++){

			for(int j=0;j<objects.length-i-1;j++){
				Comparable comparable1=(Comparable)objects[j];
				Comparable comparable2=(Comparable)objects[j+1];
				if(comparable1.compareTo(comparable2)>0){
					swap(objects,j,j+1);

				}
			}




		}
	}

	private static void swap(Object[] objects, int i, int j) {
		Object temp=objects[i];
		objects[i]=objects[j];
		objects[j]=temp;
	}


	public static void print(Object[] objects) {
		for (int i=0;i<objects.length;i++){
			System.out.println(objects[i]);
		}
	}
}
